import 'package:flutter/services.dart';

import '../../constant/channel_name_constant.dart';
import '../../network/code_msg_model.dart';
import '../../utils/log_util.dart';

///用于传递方法调用（method invocation）（双向有返回值）
class BaseMethodChannel extends MethodChannel{
  static final BaseMethodChannel  _instance = BaseMethodChannel._internal(ChannelNameConstant.methodChannelName);

  factory BaseMethodChannel() => _instance;

  BaseMethodChannel._internal(super.name);

  void initMethodChannel(){
    _instance.setMethodCallHandler((call) async {
      LogUtil.stdPrint('method = ${call.method}, arguments = ${call.arguments}');
      return baseResponseModelToJson(CodeMsgModel.success());
    });
  }
}
